#include "SandBox.h"
#include "Simulator.h"
#include "windows.h"
#include <shellapi.h>
#include "io.h"

AppSettings settings;
logwriter logFile;


INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
{
	
	   settings.loadSettings();

	   if(settings.applicationSettings.bAllowDevConsole)
	   {
			AllocConsole();
			stdout->_file=_open_osfhandle((intptr_t)GetStdHandle(STD_OUTPUT_HANDLE),0);
	   }

	   

	   if(settings.applicationSettings.bSandBoxMode)
	   {
		          // Create application object
				   SandBox app;

					printf("\n%s","--------------------------------------------------");
					printf("\n%s","Application (SandBox mode) started....");
					printf("\n%s","--------------------------------------------------");
					try {
						app.go();
					} catch( Ogre::Exception& e ) {
						MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);

					}
	   }
	   else
	   {
		   		  // Create application object
				   Simulator app;

					printf("\n%s","--------------------------------------------------");
					printf("\n%s","Application (Simulator mode) started....");
					printf("\n%s","--------------------------------------------------");
					try {
						app.go();
					} catch( Ogre::Exception& e ) {
						MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);

					}
	   }



        return 0;
}



